<template>
	<div class="table-container">
		<!--默认查询-->
		<exSearch ref="exSearch" v-model="search" @getList="getList">
			<!-- <template v-slot:SysStoreID>
				<el-form-item v-if="user.isAdminStore||user.isMainStore">
					<remoteselect v-model="search.SysStoreID" url="api/System/SysStoreListSelect" value-label="SysStoreName"
						value-key="SysStoreID" query-key="selectIDName" :placeholder="replaceID(keyLan['SysStoreID'])" style="width:150px;">
						<template v-slot="{ row }">
							{{row.SysStoreName}}
						</template>
</remoteselect>
</el-form-item>
</template> -->
		</exSearch>
		<!--默认列表-->
		<exTable ref="exTable" v-model="list" @selection-change="selectionChange"
			:showOp="button.编辑 || button.启用禁用 || button.删除" :showPage="true">
			<!-- <template v-slot:SysStore.EnumSysStoreType>
				<u-table-column type="selection" width="47"></u-table-column>
				<u-table-column prop="SysStore.EnumSysStoreType" :label="comLan['Key']['SysStore']['EnumSysStoreType']" width="80" align="center">
					<template v-slot="scope">
						<span v-html="getLabel(scope.row.SysStore.EnumSysStoreType,EnumSysStoreType)"></span>
					</template>
				</u-table-column>
			</template> -->
		</exTable>

		<!--默认新建编辑-->
		<exAddEdit ref="exAddEdit" @success="getList"></exAddEdit>
	</div>
</template>

<script>
import common from "@/common/common.js";
import js from "./js.js";
import exAddEdit from "./SysCustomerAdd";
import exSearch from "@/Auto/SysCustomer/SysCustomerListSearch.vue";
import exTable from "@/Auto/SysCustomer/SysCustomerListTable.vue";

export default {
	name: "SysCustomerList",
	mixins: [common.baseVM, js],
	components: {
		exAddEdit,
		exSearch,
		exTable,
	},
	data() {
		return {
			button: {
				查询: false,
				新建: false,
				编辑: false,
				启用禁用: false,
				删除: false,
				导出: false
			},
			search: {
				SysStoreID: null,
				EnumSysCustomerType: null,
				SysCustomerName: null,
				Phone: null,
				BirthDay: [],
				EnumStatus: 1,
				IsDemo: null,
				CreateSysEmployeeID: null,
				CreateDate: [],
				SysEmployeeID: null,
				EnumSysCustomerSource: null,
				EnumSysCustomerIntention: null,
				CertSearch03Json: null,
				CertSearch02Json: null,
				CertSearchUpdateTime: [],
				ReferrerID: null,
				EnumGender: null,
				Address: null,
				Company: null,
				Qualification: null,
			},
			isRedict: false
		};
	},
	methods: {
		selectionChange(val) {
			//console.log("selectionChange", val);
		},
		init() {
			this.loadDefaultSearch(() => {
				this.getList();
			});
		},
		btnAdd() {
			if (this.isRedict) {
				// 跳转链接
				var url = "/SysCustomer/SysCustomerAddRedict";
				this.navigateToRefresh(url);
			} else {
				this.$refs["exAddEdit"].show();
			}
		},
		btnEdit(scope) {
			if (this.isRedict) {
				// 跳转链接
				var url = "/SysCustomer/SysCustomerAddRedict";
				this.navigateToRefresh(url, {
					id: scope.row.SysCustomerID
				});
			} else {
				this.$refs["exAddEdit"].show(scope);
			}
		},
		btnEnumStatus(scope, status) {
			var id = scope.row.SysCustomerID;
			var name = scope.row.SysCustomerName;
			var str = status == 1 ? this.comLan["btnEnable"] : this.comLan["btnDisable"];
			var msg = this.stringFormat(this.comLan.js["updateEnumStatus"], name, str);
			this.confirm(msg, () => {
				this.post("api/SysCustomer/UpdateEnumStatus", this.toKeyValue({
					id: id,
					status: status
				})).then(data => {
					this.getList();
				}).catch(error => { });
			});
		},
		btnDel(scope) {
			var id = scope.row.SysCustomerID;
			var name = scope.row.SysCustomerName;
			var msg = this.stringFormat(this.comLan.js["delete"], name);
			this.confirm(msg, () => {
				this.post("api/SysCustomer/Del", this.toKeyValue({
					id: id
				})).then(data => {
					this.getList();
				}).catch(error => { });
			});
		},
		getList() {
			this.getListByUrl('api/SysCustomer/List');
		},
		btnExport() {
			this.$refs.exTable.exportFile(this.keyLan["name"]);
		},
	}
};
</script>